#include <func.h>
void cleanfunc(void *p)
{
    printf("I am cleanfunc%ld!\n",(long)p);
}
void *thfunc(void *p)
{
    pthread_cleanup_push(cleanfunc,(void*)1);
    pthread_cleanup_push(cleanfunc,(void*)2);
    printf("I am subthread!\n");
    pthread_cleanup_pop(0);
    pthread_cleanup_pop(0);
}
int main(int argc,char *argv[])
{
    int ret;
    pthread_t pthid;
    ret=pthread_create(&pthid,NULL,thfunc,NULL);
    THREAD_ERROR_CHECK(ret,"pthread_create");
    printf("I am main thread\n");
    ret=pthread_cancel(pthid);
    THREAD_ERROR_CHECK(ret,"pthread_cancel");
    ret=pthread_join(pthid,NULL);
    THREAD_ERROR_CHECK(ret,"pthread_join");
    return 0;
}

